<?php

/**
 * 73YC 评论页面
 * ============================================================================
 * * 版权所有 20013-* 梅州络客网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.alork.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: liubo $
 * $Id: index.php 17217 2013-10-19 06:29:08Z liubo $
*/

define('IN_ECS', true);

require(dirname(__FILE__) . '/includes/init.php');
/* 载入语言文件 */
require_once(ROOT_PATH . 'languages/' .$_CFG['lang']. '/user.php');


// include('region_select.php');

$user_id = $_SESSION['user_id'];
$action  = isset($_REQUEST['act']) ? trim($_REQUEST['act']) : 'default';
$order_id  = isset($_REQUEST['order_id']) ? trim($_REQUEST['order_id']) : 'default';
$affiliate = unserialize($GLOBALS['_CFG']['affiliate']);
$smarty->assign('affiliate', $affiliate);
$back_act='';

// 不需要登录的操作或自己验证是否登录（如ajax处理）的act
$not_login_arr =
array('login','act_login','register','act_register','act_edit_password','get_password','send_pwd_email','password', 'signin', 'add_tag', 'collect', 'return_to_cart', 'logout', 'email_list', 'validate_email', 'send_hash_mail', 'order_query', 'is_registered', 'check_email','clear_history','qpassword_name', 'get_passwd_question', 'check_answer');
/* 显示页面的action列表 */
$ui_arr = array( 'comment', 'login');

/* 未登录处理 */
if (empty($_SESSION['user_id']))
{
    if (!in_array($action, $not_login_arr))
    {
        if (in_array($action, $ui_arr))
        {
            if (!empty($_SERVER['QUERY_STRING']))
            {
                $back_act = 'user.php?' . strip_tags($_SERVER['QUERY_STRING']);
            }
            $action = 'login';
        }
        else
        {
            //未登录提交数据。非正常途径提交数据！
            die($_LANG['require_login']);
        }
    }
}



if($action=="comment"){
    include_once(ROOT_PATH . 'includes/lib_order.php');
    // 查询订单是否已经评论
        $sql = "SELECT comment FROM ".$GLOBALS['ecs']->table('order_info')." WHERE `order_id` =".$order_id." AND  `user_id` =".$_SESSION['user_id']." AND `order_status` ='5' AND `shipping_status` ='2' AND `pay_status` ='2'";
        $comment= $db->getRow($sql);
        if(!isset($comment)||empty($comment)){
            header("location:user.php");
        }
        $comment=$comment["comment"];
        if(!isset($comment)||$comment=="1"){
               header("location:user.php");
        }
    $orders=order_goods($order_id);
    foreach ($orders as $key => $value) {
        $orders["goods"][$value["goods_id"]]=$value;
    }
    $orders_goods=array_values($orders["goods"]);
    $smarty->assign('top_title','商品评价');
    $smarty->assign('goods',$orders_goods);
    $smarty->assign('order_id',$order_id);
    $smarty->display('comment.dwt');
}
// 未登录返回首页
elseif ($action == 'login')
{
                $url = "index.php";
                echo "<script language='javascript' type='text/javascript'>";
                echo "window.location.href='$url'";
                echo "</script>";
}













?>